local skel = fk.CreateSkill {
  name = "lb__xieyue",
}

Fk:loadTranslationTable {
  ["lb__xieyue"] = "谐乐",
  [":lb__xieyue"] = "出牌阶段限一次，你可令所有体力值大于/小于你的角色失去/回复1点体力，然后你将手牌调整至X张（X为与你体力相同的其他角色数），若X等于其他角色数，重置<a href=':lb__gongming'><font color='red'>〖共鸣〗</font></a>。",

  ["#lb__xieyue"] = "谐乐：你可以令所有体力值大于/小于你的角色失去/回复1点体力",

  ["$lb__xieyue1"] = "希望世间纷争不再。",
  ["$lb__xieyue2"] = "今夜，灵魂彼此相拥。",
}

skel:addEffect("active", {
  prompt = "#lb__xieyue",
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name, Player.HistoryPhase) == 0 and
        table.find(Fk:currentRoom().alive_players, function(p)
          return p.hp ~= player.hp
        end)
  end,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    for _, t in ipairs(room:getOtherPlayers(player)) do
      if t.hp > player.hp then
        room:loseHp(t, 1, skel.name)
      elseif t.hp < player.hp then
        room:recover {
          who = t,
          num = 1,
          skillName = skel.name,
          recoverBy = player,
        }
      end
    end
    local n = #table.filter(room:getOtherPlayers(player), function(p)
      return p.hp == player.hp
    end)
    if n == #room:getOtherPlayers(player) then
      player:setSkillUseHistory("lb__gongming", 0, Player.HistoryGame)
    end
    if player:getHandcardNum() < n then
      player:drawCards(n - player:getHandcardNum(), skel.name)
    elseif player:getHandcardNum() > n then
      n = player:getHandcardNum() - n
      room:askToDiscard(player, {
        min_num = n,
        max_num = n,
        skill_name = skel.name,
        include_equip = false,
        cancelable = false,
      })
    end
  end,
})

return skel
